Skip to content

Conversation

shamil-gadelshin
Copy link
Collaborator

@shamil-gadelshin shamil-gadelshin commented Sep 12, 2025

Root Claim / Airdrop

This PR introduces a root claim (airdrop) mechanism. It replaces the automatic selling of root-alpha dividends with accumulation. Users can either:

  • Manually claim their accumulated share, or
  • Enable auto-sell, which automatically sells the accumulated share daily and transfers the proceeds to their account.

New extrinsics

  • set_root_claim_type — Set root-claim mode: auto or manual.
  • claim_root — Manually claim accumulated root dividends.

Storage changes

  • PendingRootAlphaDivs — Tracks root-alpha dividends between epochs.
  • RootClaimType — User’s preferred claim mode (auto or manual).
  • RootClaimable — User’s claimable share of alpha dividends.
  • RootClaimed — Accounting helper for alpha dividends (stake changes, claimed amounts).
  • StakingColdkeysByIndex — Supports randomized distribution of auto-claims per block.
  • StakingColdkeys — Supports root-dividends distribution.
  • NumStakingColdkeys — Count to support randomized auto-claim distribution per block.
  • NumRootClaim — Number of auto-claims to fulfill for a subnet in the current epoch.
  • AlphaMapLastKey — Supports staking coldkey migration.

Removed (obsolete storage maps)

  • TaoDividendsPerSubnet
  • PendingAlphaSwapped

Original PRs


.checked_div(total)
.unwrap_or(I96F32::saturating_from_num(0.0));

if u64::from(amount) > total.saturating_to_num::<u64>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I think this should never happen we should probably add it to their alpha stake or something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, but it will be the same, as we'll give everything to the validator owner.

I introduced this check during the testing. Incorrect test setup produced unexpected results. It's unlikely that we have this on mainnet. And if we do have this condition - we chose a safe route.

I'm open to suggestions here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the remainder goes to the vali owner? That sounds right

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Swamination-Yuma
Copy link

Making a note from OpenDev - to assure this handles dereg liquidation scenarios.

Copy link
Contributor

@camfairchild camfairchild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to handle subnet de-reg as well. We should just claim the whole pool when the de-reg happens

continue;
}

weight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should try to grab more if some don't meet the claim threshold

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It introduces a rather awkward interface. I increased the auto-key claims instead. We had roughly a day previously, a week after a conversation with Const. I doubled the value.

@camfairchild
Copy link
Contributor

Note from nucleus call:

  • make sure auto claim threshold is per-subnet. Don't claim tiny amounts of any subnet automatically

Copy link
Collaborator Author

@shamil-gadelshin shamil-gadelshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure auto claim threshold is per-subnet. Don't claim tiny amounts of any subnet automatically

We have one threshold for all operations. Is there a reason to introduce a map of thresholds?

UPDATE: I implemented the per-subnet threshold anyway.

continue;
}

weight
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It introduces a rather awkward interface. I increased the auto-key claims instead. We had roughly a day previously, a week after a conversation with Const. I doubled the value.

weight
}

pub fn change_root_claim_type(coldkey: &T::AccountId, new_type: RootClaimTypeEnum) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could reindex these maps each 6-12month.

sam0x17
sam0x17 previously approved these changes Oct 17, 2025
@sam0x17
Copy link
Contributor

sam0x17 commented Oct 17, 2025

looks like some CI failures tho

@Swamination-Yuma
Copy link

Has someone communicated with the Bittensor SDK v10 devs to account for any changes (for the auto/manual setting and the storage map adds & removals)? May be nothing, but I was not sure offhand if directly handled since no mention in the v10 migration guide.

@sam0x17 sam0x17 added the breaking-change This PR introduces a noteworthy breaking change label Oct 17, 2025
Copy link
Contributor

@opentensor/cerebrum / @opentensor/gyrus / @opentensor/cortex breaking change detected! Please prepare accordingly!

@shamil-gadelshin
Copy link
Collaborator Author

Has someone communicated with the Bittensor SDK v10 devs to account for any changes (for the auto/manual setting and the storage map adds & removals)? May be nothing, but I was not sure offhand if directly handled since no mention in the v10 migration guide.

Yes. The SDK team was going to work on the required changes after the merge. cc @basfroman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This PR introduces a noteworthy breaking change skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants